#include <iostream>

using namespace std;

const int N = 1e5 + 10;

int h[N], e[N * 2], ne[N * 2], w[N * 2], id;

int n, m;

void add(int a, int b, int c)
{
	id++;
	e[id] = b;
	w[id] = c;
	ne[id] = h[a];
	h[a] = b;
}

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int a, b, c; cin >> a >> b >> c;
		add(a, b, c); add(b, a, c);
	}
	return 0;
}
